package com.yangqi.ThreadDemo;

public class Thread02 {
    public static void main(String[] args) {
        SayHi sayHi = new SayHi();
        Thread thread = new Thread(sayHi);
        thread.start();
    }

}
//通过实现Runnable接口，开发线程
class SayHi implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("sayHi" + i + "\t:" + Thread.currentThread().getName());
        }
    }
}
